<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ page import="java.util.Set,java.util.Iterator,java.io.IOException"%>
<%@page import="java.io.File"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%!
private void compileAllJsps(PageContext pageContext, JspWriter out, HttpServletRequest request, HttpServletResponse response, String uripath)
			throws IOException, ServletException {
		Set set = pageContext.getServletContext().getResourcePaths(uripath);
		out.write("请稍候");
		for (Iterator iter = set.iterator(); iter.hasNext();) {
			String uri = (String) iter.next();
			if (uri.endsWith(".jsp")) {
				RequestDispatcher rd = null;
				//out.write("<li>" + uri + "</li>");
				try {
					rd = getServletContext().getRequestDispatcher(uri);
					if (rd == null) {
						//throw new Error(uri +" - not found");
						//out.write(uri + " - not found");
						out.write(".");
					}else{
						rd.include(request, response);
					}
				} catch (Exception e) {
					//out.write("<br>  <font color=red size=2>"+uri + " - 编译错误：<br>" + e.getLocalizedMessage()+"</font>");
				}
				//out.flush();
			} else if (uri.endsWith("/")) {
				compileAllJsps(pageContext, out, request, response, uri);
			}
		}
	}
%>
<html>
	<head>
		<title>系统正在优化</title>		
	</head>
	<body>
		<h4>
			请稍候...
		</h4>
		<ul>
			<%				
					HttpServletRequest req = new HttpServletRequestWrapper(request) {
						public String getQueryString() {
							//can be "jsp_precompile=true"
							return "jsp_precompile";
						};
					};
					compileAllJsps(pageContext, out, req, response, "/");				
					response.sendRedirect(request.getContextPath());
			%>
		</ul>
		<h4>
			完成.
		</h4>
	</body>
</html>